<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/7/8
 * Time: 10:02
 */
namespace app\admin\validate;

use think\Validate;

class Client extends Validate{
    protected $rule = [
        'name'      => 'require|max:50',
        'shortname' => 'require|max:20',
        'appid'     => 'require|max:40',
        'balance'   => 'float',
        'linkman'   => 'max:20',
        'phone'     => ['regex'=>'/^1(?:3\d|4[4-9]|5[0-35-9]|6[67]|7[013-8]|8\d|9\d)\d{8}$/'],
        'address'   => 'max:50',
        'status'    => 'in:1,0',
    ];
    protected $message  =   [
        'name.require'      => '客户名称不能为空',
        'shortname.require' => '客户简称不能为空',
        'appid.require'     => 'appid不能为空',
        'name.max'          => '客户名称不能超过50个字符',
        'shortname.max'     => '客户简称不能超过20个字符',
        'appid.max'         => 'appid不能超过40个字符',
        'balance.float'     => '余额只能是小数',
        'linkman.max'       => '联系人不能超过20个字符',
        'phone.regex'       => '号码不正确',
        'address.max'       => '地址不能超过50个字符',
        'status.in'         => '状态不正确',
    ];
}